<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      div {
        display: flex;
        width: 300px;
        height: 300px;
        margin: 100px auto;
        justify-content: center;
        align-items: center;
      }
    </style>
  </head>
  <body>
    <div>
      <input type="text" value="" id="txt" />
      <input type="button" value="提交" id="btn" />
    </div>
  </body>
  <script>
    let Input1 = /^([A-Za-z])\w{2,10}$/g;
    txt.onblur = function () {
      console.log(Input1.test(txt.value)); //true
      if (Input1.test(txt.value)) {
        console.log("true");
      }
    };
  </script>
</html>
